//引入样式
require("../../assets/font_44fp3ls0tzq/iconfont.css");
require("../../assets/css/reset.css");
require("../../assets/css/normalize.css");
require("../../assets/css/common.css");
require("../../assets/css/tabbar.less");
require("../../assets/css/sports.less");
require("./sports_run.less");
//引入模块
const dom = require("../../utils/dom.js");
const axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	//渲染头部导航
	dom.navbar("sports_run");
	//渲染底部导航
	dom.tabBar("sports_run");
	//模态框
	dom.get(".main-there h1").addEventListener("click", function () {
		dom.get("#mask").style.display = "block";
		dom.get("#box").style.display = "block";
		let num = 3;
		setInterval(function () {
			num--;
			dom.get("#box").textContent = num;
			if (num === 0) {
				dom.get("#box").textContent = "GO";
			}
			if (num === -1) {
				location.href = "sports_running.html";
				dom.get("#box").textContent = "";
			}
			console.log(num);
		}, 1000);
	});

	//跑步数据
	axios.get("/api/exercise").then((res) => {
		if (res.data.errno === 0) {
			dom.get(".main-two h1 p").textContent = (
				res.data.data.sum7Meter / 1000
			).toFixed(2);
		}
		console.log(res.data);
	});
});
